﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class HitView : MonoBehaviour {
    public UnityAction submit = null;
	public List<HitItemView> hitlilst = new List<HitItemView>();
    public bool flag = false;
	public void UpdateItem()
    {
        for (int i = 0; i < hitlilst.Count; i++)
        {
            hitlilst[i].InitData(submit);
        }
    }
    public void Begin()
    {
        flag = true;
        Debug.Log("游戏开始1111");
        StartCoroutine(GameBegin());
    }
    public void Over()
    {
        flag = false;
        StopCoroutine(GameBegin());
        for (int j = 0; j < hitlilst.Count; j++)
        {
             hitlilst[j].PosDown();
        }
    }
    IEnumerator GameBegin()
    {
        if(flag)
        {
            Debug.Log("开始出怪");
            for (int i = 0; i < 10; i++)
            {
                yield return new WaitForSeconds(1);
                int num = Random.Range(0, hitlilst.Count);
                for (int j = 0; j < hitlilst.Count; j++)
                {
                    if(num==j)
                    {
                        hitlilst[num].PosUp();
                        break;
                    }
                }
            }
        }
    }
}
